<template>
  <div id="operationLogTop">
    <el-row :gutter="24">
      <el-col :span="6">
        <el-input v-model="params.username" placeholder="请输入用户名" /> 
      </el-col>
      <el-col :span="12" class="datePicker">
        <el-date-picker
          v-model="time"
          type="datetimerange"
          :picker-options="pickerOptions"
          value-format="yyyy-MM-dd HH:mm:ss"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          align="right">
        </el-date-picker>
      </el-col>
      <el-col :span="3">
        <el-button type="primary" round @click="selectOperationLogParams">
          <i class="iconfont icon-sousuo size" />
          查询
        </el-button>
      </el-col>
      <el-col :span="3">
        <el-button type="primary" round @click="exportOperationLog">
          <i class="iconfont icon-daochu size" />
          导出
        </el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>

import {
  exportOperationLog
} from '@/assets/request/api.js';
export default {
  name: 'operationLogTop',
  data() {
    return {
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      time: [],
      params: {
        username: '',
        beginTime: '',
        endTime: ''
      }
    }
  },
  methods: {
    selectOperationLogParams() {
      this.params.beginTime = this.time[0]
      this.params.endTime = this.time[1]
      this.$emit("selectOperationLogParams",this.params)
    },
    exportOperationLog() {
      
      exportOperationLog(this.params).then(res => {

        this.$message({
          message: '导出成功',
          type: 'success'
        });

      }).catch(err => {
        this.$message({
          message: '导出失败',
          type: 'error'
        });
      })


    }
  },
 
    
}
</script>

<style scoped lang="scss">

.el-input /deep/ .el-input__inner{ 
  height: 32px;
  font-size: 13px;
  box-shadow: none;
  border: 1px solid #e9e9e9;
}


.el-button {
  line-height: 0px;
  height: 32px;
  padding: 12px;
  border-radius: 20px;
  margin-left: 12px;
  .size {
    font-size: 4px;
  }
}

.el-range-editor.el-input__inner {
  height: 32px ;
  font-size: 13px;
  box-shadow: none;
  border: 1px solid #e9e9e9;
}

.datePicker  /deep/ .el-range-separator {
  height: 32px !important;
}

.datePicker  /deep/ .el-range__icon {
  height: 32px;
}

.datePicker /deep/ .el-range__close-icon {
  height: 32px;
}


 
</style>
